<template>
	<view class="" style="background-color: #F8F8F8;">
		<view class="nav-back">
			<top-heigth :backTitle="backTitle"></top-heigth>
		</view>
		<view class="kong-box" v-if="list.length == 0">
			<uv-empty mode="" text="还没有优惠券，去领券专区看看吧~" icon="/static/image/kong-quan.png"></uv-empty>
		</view>
		<view class="content-box" v-else>
			<view class="public-box m-b16 m-t24">
				<template v-for="item in list">
					<view class="coupon-box">
						<view class="coupon-top" @click="backToOrder(item)">
							<view class="coupon-l-box">
								<view class="coupon-l">
									 <view class="coupon-l-red">
									 	<span>¥</span>{{item.tAppCouponVo.couponAmount}}
									 </view>
									<view class="coupon-l-black">满{{item.tAppCouponVo.couponLimitAmount}}可用</view>
								</view>
								<view class="coupon-c">
									<view><b>{{item.tAppCouponVo.couponName}}</b></view>
									<view v-if="item.tAppCouponVo.beginTime!=null" class="font-hui m-t16">
										{{(item.tAppCouponVo.beginTime).substring(0,10)}}-{{(item.tAppCouponVo.endTime).substring(0,10)}}
									</view>
								</view>
							</view>
							<!-- <view class="coupon-but-red">立即领取</view> -->
						</view>
						<view class="coupon-bottom">
							<view class="font-hui">全场通用</view>
							<view v-if="item.tAppCouponVo.couponType == 1" class="font-hui">新用户可领</view>
							<view v-if="item.tAppCouponVo.couponType == 2" class="font-hui">老用户可领</view>
						</view>
					</view>
				</template>
			</view>
		</view>
	</view>
</template>

<script>
	import TopHeigth from '@/components/TopHeigth.vue'
	
	export default {
		data() {
			return {
				backTitle:"我的优惠券",
				list:[],
				userInfo: uni.getStorageSync('userInfo'),
				backSign: false
			}
		},
		components: { TopHeigth },
		onLoad(e) {
			this.backSign = e.sign
			this.myList()
		},
		methods: {
			myList(){
				uni.$u.http.post('/api/shop/v1_0/tAppCouponUserRCA/queryTAppCouponUser',{
					appUserId: this.userInfo.id,
					orderIdIsNUll: 1
				}).then((res) => {
					this.list = res.aaData
				})
			},
			backToOrder(coupon){
				if(this.backSign){
					uni.$emit('selectCoupon', coupon)
					uni.navigateBack()					
				}
			},
		}
	}
</script>

<style lang="scss" scoped>
	@mixin flex($direction: row) {
		/* #ifndef APP-NVUE */
		display: flex;
		/* #endif */
		flex-direction: $direction;
	}
	.uv-nav-slot {
		@include flex;
		align-items: center;
		justify-content: space-between;
		border-width: 0.5px;
		border-radius: 100px;
		border-color: #dadbde;
		padding: 3px 7px;
		opacity: 0.8;
	}
	
	.coupon-box{
		height: 236rpx;
		border-radius: 20rpx;
		border: 3rpx solid #f9c9b4;
		background:#fff3f0 url("/static/image/coupon.png") right no-repeat;
		background-size: auto 236rpx;
		padding: 0 30rpx;
		margin-bottom: 20rpx;
	}
	.coupon-top{
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 30rpx 0;
	}
	.coupon-bottom{
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-top: 2rpx dashed #D8D8D8;
	}
	.coupon-l{
		padding-right: 24rpx;
	}
	.coupon-c{
		padding-left: 24rpx;
		border-left: 2rpx solid #D8D8D8;
	}
	.coupon-l-red{
		font-size: 56rpx;
		color: #FF0202;
		font-weight: bold;
		span{
			font-size: 34rpx;
		}
	}
	.coupon-but-red{
		height: 56rpx;
		border-radius: 56rpx;
		padding: 0 20rpx;
		text-align: center;
		line-height:56rpx;
		color: #fff;
		font-size: 24rpx;
		background-color: #F51212;
	}
	.coupon-l-box{
		display: flex;
		align-items: center;
		justify-content: flex-start;
	}
	.coupon-l-black{
		font-size: 24rpx;
		color: #333;
	}
	.coupon-c{
		font-size: 30rpx;
		color: #333;
	}
	.coupon-bottom{
		padding: 20rpx 0;
	}
</style>
